package com.fr.plugin.customloginpage.service;

import com.fr.json.JSONObject;
import com.fr.plugin.customloginpage.config.Config;
import com.fr.plugin.customloginpage.config.CustomConfig;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class ConfigSaveHttpHandler extends AbstractHttpHandler {
    public static final String SAVE_PATH = "/saveConfig";

    @Override
    public String urlPath() {
        return SAVE_PATH;
    }

    @Override
    public void deal(HttpServletRequest req, HttpServletResponse res, JSONObject para, JSONObject result) throws Exception {
        Config instance = Config.getInstance();
        CustomConfig config = new CustomConfig();
        config.setJsonStr(para.toString());
        instance.setCustomConfig(config);
        result.put(AbstractHttpHandler.STATE_NAME, true);
        System.out.println(para.toString());
    }

}
